/*
    Handling of IPv4 range lists for implementation of black- and whitelists.

    Copyright (C) 2005 by Peer of the Beer & modifications by Yello

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
    MA 02111-1307 USA
*/

#ifndef IPV4_LIST_H__INCLUDED
#define IPV4_LIST_H__INCLUDED 1

/* Read blacklist file.  Return number of ranges loaded.
   Return -1 if file is not found. */
int ipv4_black_list_read(const char *file_name);

/* Return non-zero if the address is in the blacklist.
   Parameter addr is an ip number in network byte order.
   If parameter descr_ret is non-NULL and return value is non-zero,
   the descr_ret returns a comment description from the matching
   range.  Returned description can also be NULL, if it's not
   known or empty. Description is not to be freed by the caller.
   Description stays valid until blacklist is reloaded or lists
   are cleared. */
int ipv4_black_list_match(uint32_t addr, char **descr_ret);

/* Read whitelist file.  Return number of ranges loaded.
   Return -1 if file is not found. */
int ipv4_white_list_read(const char *file_name);

/* Return non-zero if the address is in the whitelist.
   Parameter addr is an ip number in network byte order.
   If parameter descr_ret is non-NULL and return value is non-zero,
   the descr_ret returns a comment description from the matching
   range.  Returned description can also be NULL, if it's not
   known or empty. Description is not to be freed by the caller.
   Description stays valid until whitelist is reloaded or lists
   are cleared. */
int ipv4_white_list_match(uint32_t addr, char **descr_ret);

/* Clear both lists. */
void ipv4_clear_lists(void);

#endif /* ! IPV4_LIST_H__INCLUDED */
